package com.fpt.edu.vn.h2tv.dao.entity;

import static javax.persistence.GenerationType.IDENTITY;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

/**
 * TbAccount entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "tb_account", catalog = "bookdb", uniqueConstraints = @UniqueConstraint(columnNames = "USERNAME"))
public class TbAccount implements java.io.Serializable {

	// Fields

	private Long userid;
	private String username;
	private String password;
	private String avatar;
	private String firstname;
	private String lastname;
	private String phonenumber;
	private String address;
	private String role;
	private String email;
	private Boolean isBanned;
	private List<TbComment> tbComments = new ArrayList<TbComment>(0);
	private List<TbOrder> tbOrders = new ArrayList<TbOrder>(0);

	// Constructors

	/** default constructor */
	public TbAccount() {
	}

	/** minimal constructor */
	public TbAccount(String username, String password, String firstname,
			String lastname, String phonenumber, Boolean isBanned) {
		this.username = username;
		this.password = password;
		this.firstname = firstname;
		this.lastname = lastname;
		this.phonenumber = phonenumber;
		this.isBanned = isBanned;
	}

	/** full constructor */
	public TbAccount(String username, String password, String avatar,
			String firstname, String lastname, String phonenumber,
			String address, String role, Boolean isBanned,
			List<TbComment> tbComments,
			List<TbOrder> tbOrders) {
		this.username = username;
		this.password = password;
		this.avatar = avatar;
		this.firstname = firstname;
		this.lastname = lastname;
		this.phonenumber = phonenumber;
		this.address = address;
		this.role = role;
		this.isBanned = isBanned;
		this.tbComments = tbComments;
		this.tbOrders = tbOrders;
	}

	@Column(name="EMAIL")
	public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    // Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "USERID", unique = true, nullable = false)
	public Long getUserid() {
		return this.userid;
	}

	public void setUserid(Long userid) {
		this.userid = userid;
	}

	@Column(name = "USERNAME", unique = true, nullable = false)
	public String getUsername() {
		return this.username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	@Column(name = "PASSWORD", nullable = false)
	public String getPassword() {
		return this.password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	@Column(name = "AVATAR")
	public String getAvatar() {
		return this.avatar;
	}

	public void setAvatar(String avatar) {
		this.avatar = avatar;
	}

	@Column(name = "FIRSTNAME", nullable = false)
	public String getFirstname() {
		return this.firstname;
	}

	public void setFirstname(String firstname) {
		this.firstname = firstname;
	}

	@Column(name = "LASTNAME", nullable = false)
	public String getLastname() {
		return this.lastname;
	}

	public void setLastname(String lastname) {
		this.lastname = lastname;
	}

	@Column(name = "PHONENUMBER", nullable = false, length = 12)
	public String getPhonenumber() {
		return this.phonenumber;
	}

	public void setPhonenumber(String phonenumber) {
		this.phonenumber = phonenumber;
	}

	@Column(name = "ADDRESS")
	public String getAddress() {
		return this.address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	@Column(name = "ROLE")
	public String getRole() {
		return this.role;
	}

	public void setRole(String role) {
		this.role = role;
	}

	@Column(name = "IS_BANNED", nullable = false)
	public Boolean getIsBanned() {
		return this.isBanned;
	}

	public void setIsBanned(Boolean isBanned) {
		this.isBanned = isBanned;
	}


	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "tbAccount")
	public List<TbComment> getTbComments() {
		return this.tbComments;
	}

	public void setTbComments(List<TbComment> tbComments) {
		this.tbComments = tbComments;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "tbAccount")
	public List<TbOrder> getTbOrders() {
		return this.tbOrders;
	}

	public void setTbOrders(List<TbOrder> tbOrders) {
		this.tbOrders = tbOrders;
	}

}